<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        // 构造函数定义实例属性
         function Person(name, age, job) {
            this.name = name;
            this.age = age;
            this.job = job;
        }

        // 原型模式构造函数
        Person.prototype = {
            constructor: Person,
            sayName: function () {
                alert(this.name);
            }
        };

        var p1=new Person("aa",12,"aa");
        var p2=new Person("bb",12,"bb");

        alert(p1.name  +":"+ p2.name)
        alert(p1.sayName === p2.sayName);



        /// 动态原型模式
/*
        function Person(name, age, job) {
            this.name = name;
            this.age = age;
            this.job = job;

            if (typeof this.sayName != 'function') {
                Person.prototype.sayName = function () {
                    alert(this.name);
                }
            }
        }

*/
    </script>
</head>
<body>
组合使用构造函数和原型模式
， 动态原型模式
</body>
</html>